$(function(){
 	$("#index-left a").click(function(){
		var e =$(this).attr("name");
		$("#content").attr("src",e);
		return false;
	});
 	$("#backToIndex").click(function(){
		$("#content").attr("src",js+"index.action");
		return false;							 
	})
	$("#exitSys").click(function(){
		$.post(js+'system/exitOperator.action',function(result){
		     if(result.success){
		     	window.top.location.href=js+"login.jsp";
		      }else{
		          $.messager.alert('提示',"退出不成功!!!","error");	
		      }
		},"json");
		
	});
	$("#windowStyle1").click(function(){
		windowStyleChange('v1');
		return false;							 
	})
	$("#windowStyle2").click(function(){
		windowStyleChange('v2');
		return false;							 
	})
	
	$("#modifyPwd").click(function(){
		$('#modifyPwdDialog').dialog('open');
		return false;							 
	})
	
	$('#modifyPwdDialog').dialog({
		 	modal:true,
		 	closed:true,
			toolbar:[{
				text:'保存',
				iconCls:'icon-save',
				handler:function(){
	                 $('#modifyPwdForm').form('submit',{
	    				url: js+'system/updatePasswordOperator.action',
	    				onSubmit: function(){
	    					 if($(this).form('validate')){
										    					 
	    					 	var newPassword=$("#newPassword").val();
	    					 	var reNewPassword=$("#reNewPassword").val();
	    					 	if(newPassword!=reNewPassword){
	    					 		$.messager.alert('提示：','新密码和确认新密码输入不一致！！','error');
	    					 		return false;
	    					 	}
	    					 	return true;
	    					 }else{
	    					 	$.messager.alert('提示：','请填写完整信息','error');
	    					 	return false;
	    					 }
	    				},
	    				success: function(data){
	    					var result = eval('('+data+')');
	    					if (result.success){
	    						$.messager.alert('提示：','修改密码成功','info');
	    						$('#modifyPwdDialog').dialog('close');
	    					} else {
    							$.messager.alert('提示：','修改密码失败','error');
	    					}
	    				}
	    			});
				}
			 },'-',{
				text:'取消',
				iconCls:'icon-cancel',
				handler:function(){
					$('#modifyPwdDialog').dialog('close');
				}
			}]
		});
	$("#password").validatebox({
		required:"true" ,
		validType:"remote['"+js+"system/validatePasswordOperator.action','password']",
		invalidMessage:"原密码输入不正确"
	
	})
})



function windowStyleChange(windowStyle){
	$.post(js+'system/changeWindowStyleOperator.action',{windowStyle:windowStyle},function(result){
		     if(result.success){
		     	window.top.location.href=js+"main.action";
		      }else{
		          $.messager.alert('提示',"修改风格不同!!!","error");	
		      }
		},"json");
}